//
//  SpecialTopView.m
//  BTRIP
//
//  Created by dllo on 15/11/22.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "SpecialTopView.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation SpecialTopView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)dealloc{
    [_imageViewOfBackground release];
    [_labelOfName release];
    [_labelOfDash release];
    [_labelOfTitle release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView{
    self.imageViewOfBackground = [[UIImageView alloc]init];
    [self addSubview:self.imageViewOfBackground];
    [self.imageViewOfBackground release];
    self.labelOfName = [[UILabel alloc]init];
    [self addSubview:self.labelOfName];
    [self.labelOfName release];
    self.labelOfDash = [[UILabel alloc]init];
    [self addSubview:self.labelOfDash];
    [self.labelOfDash release];
    self.labelOfTitle = [[UILabel alloc]init];
    [self addSubview:self.labelOfTitle];
    [self.labelOfTitle release];
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.imageViewOfBackground.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.labelOfName.frame = CGRectMake(0, 0, self.frame.size.width, 40);
    self.labelOfName.textColor = [UIColor whiteColor];
    self.labelOfName.font = [UIFont systemFontOfSize:18];
    self.labelOfName.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height - 100);
    self.labelOfName.textAlignment = NSTextAlignmentCenter;
    self.labelOfDash.frame = CGRectMake(self.labelOfName.frame.origin.x, self.labelOfName.frame.origin.y + self.labelOfName.frame.size.height, self.labelOfName.frame.size.width, 40);
    self.labelOfDash.text = @"————————— —————————";
    self.labelOfDash.textColor = [UIColor whiteColor];
    self.labelOfTitle.textColor = [UIColor whiteColor];
    self.labelOfTitle.frame = CGRectMake(self.labelOfDash.frame.origin.x, self.labelOfDash.frame.origin.y + self.labelOfDash.frame.size.height, self.labelOfName.frame.size.width, 30);
    self.labelOfTitle.font = [UIFont systemFontOfSize:14];
    self.labelOfTitle.textAlignment = NSTextAlignmentCenter;
    self.labelOfDash.textAlignment = NSTextAlignmentCenter;
}

-(void)setBigSpecial:(FirstSpecialBigModel *)bigSpecial{
    if (_bigSpecial != bigSpecial) {
        [_bigSpecial release];
        _bigSpecial = [bigSpecial retain];
    }
    NSURL *url = [NSURL URLWithString:bigSpecial.image_url];
    [self.imageViewOfBackground sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"background"]];
    self.labelOfName.text = bigSpecial.name;
    self.labelOfTitle.text = bigSpecial.title;
}

@end
